#include <cstdio>

typedef long long ll;
typedef unsigned int uint;
const uint N = 1000005, M = 20, mod = 1e9 + 7;
uint n, q, r, cnt, f[N][M], low[N];
bool vis[N];

uint g(uint R, uint x) {
  if (!x) return 1;
  if (!R) return 2;
  if (f[R][x]) return f[R][x];
  for (uint i = 0; i <= x; ++i) {
    f[R][x] += g(R - 1, i);
    if (f[R][x] >= mod) f[R][x] -= mod;
  }
  return f[R][x];
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("CF757E Bash Plays with Functions.in", "r", stdin);
  freopen("CF757E Bash Plays with Functions.out", "w", stdout);
#endif
#endif

  for (uint i = 2; i < N; ++i) {
    if (!vis[i]) {
      for (uint j = 1; j * i < N; ++j) { low[j * i] = i, vis[j * i] = true; }
    }
  }
  scanf("%u", &q);
  while (q--) {
    scanf("%u%u", &r, &n);
    uint cnt, tmp;
    ll ans = 1;
    while (n != 1) {
      cnt = 0, tmp = low[n];
      while (n % tmp == 0) { n /= tmp, ++cnt; }
      ans *= g(r, cnt);
      if (ans >= mod) ans %= mod;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
